package com.library.web.controller.app;

import com.library.common.annotation.Log;
import com.library.common.core.controller.BaseController;
import com.library.common.core.domain.AjaxResult;
import com.library.common.core.page.TableDataInfo;
import com.library.common.enums.BusinessType;
import com.library.common.utils.poi.ExcelUtil;
import com.library.domain.AppJoinActivity;
import com.library.service.IAppJoinActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-04-17
 */
@RestController
@RequestMapping("/library/appJoinActivity")
public class AppJoinActivityController extends BaseController {
    @Autowired
    private IAppJoinActivityService appJoinActivityService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppJoinActivity appJoinActivity) {
        startPage();
        List<AppJoinActivity> list = appJoinActivityService.selectAppJoinActivityList(appJoinActivity);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppJoinActivity appJoinActivity) {
        List<AppJoinActivity> list = appJoinActivityService.selectAppJoinActivityList(appJoinActivity);
        ExcelUtil<AppJoinActivity> util = new ExcelUtil<>(AppJoinActivity.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(appJoinActivityService.selectAppJoinActivityById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppJoinActivity appJoinActivity) {
        return toAjax(appJoinActivityService.insertAppJoinActivity(appJoinActivity));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppJoinActivity appJoinActivity) {
        return toAjax(appJoinActivityService.updateAppJoinActivity(appJoinActivity));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('library:appJoinActivity:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(appJoinActivityService.deleteAppJoinActivityByIds(ids));
    }
}
